
<template>
	<!-- 添加弹框 -->
	<el-dialog  title=""  visible :show-close="false" :modal-append-to-body="false" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
	    <div class="bt">添加学生</div>
		<div class="input-block" style="margin-top: 20px;">
			<span>学生名称</span>
			<el-input v-model="vzwm" placeholder="请选择学生名称" icon="add"  class="input"></el-input>
		    <el-button size="small" @click="xuanze()" class="select-block2" >选择</el-button>
		</div>
		<div class="input-block" style="margin-right: 60px;">
			<span>转入学校</span>
			<el-select v-model="vzrxx" placeholder="请选择转入学校" class="input">
                      <el-option :label="v.mc" :value="v.id"  v-for="v in comboxlist"></el-option>
            </el-select>
		</div>
		<div class="input-block" style="margin-right: 60px;">
			<span>备注</span>
			<el-input v-model="vnote" type="textarea" :rows="4" placeholder="请输入备注" icon="add" class="input1"></el-input>
		</div>
		<Allxs v-if="portComponents.allxs.toggle"  @close="componentsHide"  :params="portComponents.allxs.params" ></Allxs>

        <div class="an" style="text-align: center;">
		<el-button type="primary" class="submit" @click="submit">添加</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
		</div>
	</el-dialog>
</template>
<script type="text/javascript">
	import Allxs from './allxs'
	import qs from 'qs'
	export default {
		props: ['params'],
		components: { Allxs},
		data() {
			return {
				vfxkcidmc:'',
//				jg: '',
                vzwm:'',
                xsid:'',
                vzrxx:'',
				vnote:'',
				comboxlist:[],
				dialogTableVisible: true,
				portComponents: {
						allxs: {
								type: 'allxs',
								toggle: false,
								params: '',
								data: {}
						}
				},
			}
		},
		created() {
			if(this.params){
				this.vzwm = this.params.row.zwm
				this.xsid = this.params.row.id
			}
			this.getcomlist();
		},
		methods: {
			xuanze(){
				this.portComponents.allxs.toggle = true
			},
			getcomlist(){
				var logininfo = JSON.parse(localStorage.logininfo) ;
				var params3 = qs.stringify({
					yhid:logininfo.id,
					xxid:logininfo.xxid,
				});
					this.searchLoading = true;
					this.axios.post(this.$store.state.api + 'xx/list1',params3)
					.then( res => {
						console.log(res,'sssssssssssss')
							let data = res.data.data;
							let list = data.list;
							this.comboxlist=list;
					}).catch( res => {
							this.searchLoading = false;
					})
			},
			submit() {
				//检测
				this.$store.state.loading = true;
			   if(!this.vzwm) {
					this.$message.warning('请选择学生名称');
					this.$store.state.loading = false;
					return;
				}else if(!this.vzrxx){
					this.$message.warning('请选择转入校区');
					this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					xsid: this.xsid,
					zrxx: this.vzrxx,
					note: this.vnote,
					yhid: logininfo.id,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'xszxjl/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$message.success(res.data.msg);
							this.$store.state.loading = false;
						} else {
							this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.danger("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			},
			componentsShow (type,data) { //显示组件
						for ( let i in this.portComponents ) {
								if (type == this.portComponents[i].type) {
										console.log(this.portComponents[i])
										this.portComponents[i].toggle = true;
										this.portComponents[i].params = data;
										if (this.portComponents[i].data.type == 'single') {
												this.portComponents[i].data.index = data.row.id
										}else if(this.portComponents[i].data.type == 'multiple'){
												this.portComponents[i].data.index = this.multipleDelNum;
										}else{
												return;
										}
										return;
								}
						}

				},
				componentsHide (setting) { //关闭组件
						if(setting.data){
								this.vzwm = setting.data[0].zwm
								this.xsid = setting.data[0].id
								// this.vje = setting.data[0].jg
								for ( let i in this.portComponents ) {
										if (setting.type == this.portComponents[i].type) {
												this.portComponents[i].toggle = false;
												if (this.portComponents[i].type == 'singleDelete') {
														this.dataList.splice(setting.index,1)
												}
												return;
										}
								}
						}else{
							for ( let i in this.portComponents ) {
			                    if (setting.type == this.portComponents[i].type) {
			                        this.portComponents[i].toggle = false;
			                        if (!setting.cancel) {

			                        }
			                        return;
			                    }
			                }
						}
						}
		},
		 
	}
</script>
<style lang="less" scoped>
	.wrap {
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close{
				z-index: 10;
				position: absolute;
		}
		.input {
			width: 300px;
			display: inline-block;
		}
		.input1 {
			width: 300px;
			display: inline-block;
			vertical-align: middle;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
		}
	}
</style>
